import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/components/Index'
import Login from '../components/lore/Login.vue'
import Register from '../components/lore/Register.vue'
Vue.use(Router)

const router=new Router({
  routes: [
    {path: '/', name: 'Index', component: Index},
    {path: '/lore/Login', name: 'Login', component: Login},
    {path: '/lore/Register', name: 'Register', component: Register}

  ]
});
router.beforeEach(function (to,from,next) {
  if(to.path!='/lore/login' && !localStorage.token ){
    next('/login')
    return
  }
  next();
})

export default router;
